using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Data.Entity.Database;

namespace CitizenJournalismNetworkServer.Models
{
    public class CitizenJournalismNetworkServerContext : DbContext
    {
        public DbSet<CitizenJournalismNetworkServer.Models.ContentType> ContentTypes { get; set; }
    
        public DbSet<CitizenJournalismNetworkServer.Models.Collection> Collections { get; set; }
    
        public CitizenJournalismNetworkServerContext()
        {
            // Instructions:
            //  * You can add custom code to this file. Changes will *not* be lost when you re-run the scaffolder.
            //  * If you want to regenerate the file totally, delete it and then re-run the scaffolder.
            //  * You can delete these comments if you wish
            //  * If you want Entity Framework to drop and regenerate your database automatically whenever you 
            //    change your model schema, uncomment the following line:
			DbDatabase.SetInitializer(new DropCreateDatabaseIfModelChanges<CitizenJournalismNetworkServerContext>());
            
        }

        protected override void OnModelCreating(System.Data.Entity.ModelConfiguration.ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            // A collection has many Content Types, and Content Type may be part of a Collection.
            modelBuilder.Entity<Collection>().HasMany<ContentType>(collection => collection.AcceptedTypes);

        }
    }
}